<template>
  <div id="app">
<!--    <el-carousel :autoplay="false" direction="vertical" height="100vh">-->
<!--      <el-carousel-item v-for="item in imgList" :key="item.id">-->
<!--        <img :src="item.src" style="height:100%;width:100%;" :title="item.title"/>-->
<!--      </el-carousel-item>-->
<!--    </el-carousel>-->
    <vanta-img ></vanta-img>
    <el-container>
      <el-header>
        <div class="el-icon-user-solid">
          <span>  Xiao Zuo's Blog Webside</span>
        </div>

        <div >
          <el-tooltip placement="bottom">
            <div slot="content">

              <img class="img_style" :src="img_src2"/>
            </div>
            <el-button class="el-icon-s-custom" circle></el-button>
          </el-tooltip>
        </div>

      </el-header>
      <el-main>
      </el-main>
    </el-container>

    <el-card class="weather">
      <ul style="font-size:300%;
          text-align: center;">
        <li style="list-style-type: none"><i class="el-icon-cloudy-and-sunny"></i>
        </li>
      </ul>
      <p style="font-size: 50px">{{ this.weatherInfo.temperature + '℃' }}</p><br/>
      <p style="font-size: 20px;text-align: center">{{ this.weatherInfo.weather }}</p><br/>
      <p style="text-align: right" class="el-icon-location-outline">{{ this.weatherInfo.city }}</p><br/>
      <p style="text-align: right" class="el-icon-position">{{ '风速:' + this.weatherInfo.windpower }}</p><br/>
    </el-card>
    <el-card class="yiqing" style="width: 800px;text-align: center" v-loading="loading"
             element-loading-text="拼命加载中"
             element-loading-spinner="el-icon-loading"
             element-loading-background="rgba(0, 0, 0, 0.8)">
      <el-row :gutter="20">
        <el-col :span="4">
          <p>查询地区</p>
          <p style="font-size: 30px;margin-top: 30px">{{ this.yiqing.查询地区 }}</p>
        </el-col>
        <el-col :span="4">
          <p>新增确诊</p>
          <p style="color: gray;font-size: 30px;font-weight: bold;margin-top: 30px">{{ this.yiqing.新增确诊 }}</p>
        </el-col>

        <el-col :span="4">
          <p>现存确诊</p>
          <p style="color: gray;font-size: 30px;font-weight: bold;margin-top: 30px">{{ this.yiqing.现存确诊 }}</p>
        </el-col>
        <el-col :span="4">
          <p>目前确诊</p>
          <p style="color: gray;font-size: 30px;font-weight: bold;margin-top: 30px">{{ this.yiqing.目前确诊 }}</p>
        </el-col>
        <el-col :span="4">
          <p>治愈人数</p>
          <p style="color: gray;font-size: 30px;font-weight: bold;margin-top: 30px">{{ this.yiqing.治愈人数 }}</p>
        </el-col>
        <el-col :span="4">
          <p>死亡人数</p>
          <p style="color: gray;font-size: 30px;font-weight: bold;margin-top: 30px">{{ this.yiqing.死亡人数 }}</p>
        </el-col>

      </el-row>

    </el-card>
    <el-card class="loginFROM" style="min-width:390px">
      <p style="margin-left: 10px;margin-bottom:40px;text-align: left;"><span style="font-size: 40px;color: rgba(255, 255, 255, 0.5)">登&nbsp;录</span>&nbsp;&nbsp;<span>没有账号?</span><span><el-link
          type="primary" @click="dialogVisible = true">来注册一个吧</el-link></span></p>
      <el-form :model="loginForm" ref="loginFormRef" :rules="loginRules" class="login_form" label-width="0px">
        <!--账号-->
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" placeholder="请输入用户名">
            <i slot="prefix" class="el-icon-user-solid"></i>
          </el-input>
        </el-form-item>
        <!--密码-->
        <el-form-item prop="password">
          <el-input show-password v-model="loginForm.password" placeholder="请输入密码">
            <i slot="prefix" class="el-icon-key"></i>
          </el-input>
        </el-form-item>
        <!--按钮-->
        <el-form-item class="btns">
          <el-button class="el-icon-s-promotion"
                     type="primary"
                     @click="login"
                     round>
          </el-button>

          <el-button class="el-icon-refresh-right"
                     type="info"
                     round>
          </el-button>
        </el-form-item>

      </el-form>
      <!--      <el-divider content-position="right">-->
      <!--        <el-link type="info"></el-link>-->
      <!--      </el-divider>-->
    </el-card>


    <!--   注册弹出框-->
    <el-dialog
        title="注册账号"
        :visible.sync="dialogVisible"
        width="30%"
    >

      <el-form :model="regUserForm" ref="regUserFormRef" :rules="regUserForm" class="login_form" label-width="0px">
        <el-form-item prop="username">
          <el-input v-model="regUserForm.username"  placeholder="请输入用户名">
            <i slot="prefix" class="el-icon-user-solid"></i>
          </el-input>
        </el-form-item>
        <!--密码-->
        <el-form-item prop="password">
          <el-input show-password v-model="regUserForm.password" placeholder="请输入密码">
            <i slot="prefix" class="el-icon-key"></i>
          </el-input>
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
    <el-button @click="dialogVisible = false">取 消</el-button>
    <el-button type="primary" @click="regUser">确 定</el-button>
  </span>
    </el-dialog>
<!--    发博客的抽屉弹出框-->



  </div>
</template>

<script>
import axios from "axios";
import qs from "qs";

export default {
  name: "blog_login",
  data() {
    return {
      loading: true,
      yiqing: '',
      img_icon: [
        {
          weather: '多云',
          icon: 'el-icon-cloudy-and-sunny'
        },
        {
          weather: '晴',
          icon: 'el-icon-sunny'
        },
      ],
      img_src2: require('@/assets/wechart.jpg'),
      visible: false,
      dialogVisible: false,
      imgList: [
        {src: require("@/assets/IMG_20210723_183356.jpg")},
        {src: require("@/assets/IMG_20220225_160440.jpg")}
      ],
      weatherInfo: {
        weather: '',
        temperature: '',
        winddirection: '',
        reporttime: '',
        city: '',
        windpower: ''
      },
      loginForm: {
        username: 'zuowentao',
        password: '000000'
      },
      regUserForm: {
        username: '',
        password: ''
      },
      loginRules: {
        username: [
          {required: true, message: '请输入账户', trigger: 'blur'},],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
        ]
      },
      regUserRules: {
        username: [
          {required: true, message: '请输入账户', trigger: 'blur'},],
        password: [
          {required: true, message: '请输入密码', trigger: 'blur'},
        ]
      }
    }
  },
  methods: {
    goVanta(){
      this.$router.push('./vanta')
    }
    ,
    tainzhuan(){
      this.$router.push('./demo')
    },
    login() {
      this.$post('/api/login', this.loginForm).then(res => {
        if (res.status !== 200) return this.$message.error('登录失败,请检查用户名和密码')
        this.$notify({
          title: '登录成功',
          type: 'success',
          offset: 800
        })
        this.$router.push('/home')
        localStorage.setItem('token', res.token)
      })

    },
    regUser() {
      this.$post('/api/reguser', this.regUserForm).then(res => {
        if (res.status !== 200) return this.$message.error('注册失败')
        this.dialogVisible = false
        this.$notify({
          title: '注册成功',
          type: 'success',
          message: '请牢记您的账号密码',
          offset: 800
        })
      })
    },
    async getWeather() {
      const {data: res} = await axios.get('https://restapi.amap.com/v3/weather/weatherInfo?parameters', {
        params: {
          key: '8749b55299ac4f3d194a9006b6f3a4aa',
          city: '340000'
        }
      })
      this.weatherInfo.weather = res.lives[0].weather
      this.weatherInfo.winddirection = res.lives[0].winddirection
      this.weatherInfo.city = res.lives[0].city
      this.weatherInfo.windpower = res.lives[0].windpower
      this.weatherInfo.temperature = res.lives[0].temperature
      console.log(this.weatherInfo)
    },
    async getYiQing() {
      const {data: res1} = await axios.get('https://api.iyk0.com/yq/?msg=安徽')

      this.yiqing = res1
      console.log(res1)
      if (res1.code == 200) {
        this.loading = false
      }
    }
  },
  created() {
    localStorage.clear()
    this.getWeather();
    this.getYiQing();
  }


}
</script>

<style lang="less" scoped>
* {
  padding: 0;
  margin: 0;
  border: 0;
}

/deep/ p {
  font-family: "Microsoft YaHei UI Light";
}

.el-carousel {
  position: absolute;
  height: 100%;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  z-index: 0;
  opacity: 0;
  animation: bottomBtn 0.5s linear 100ms forwards;

}

@keyframes bottomBtn {
  to {
    opacity: 1;
  }
  from {
    opacity: 0;
  }
}

.el-header {
  background-color: rgba(0, 0, 0, 0.3);
  color: white;
  display: flex;
  justify-content: space-between;
  align-items: center;
  text-align: center;
  line-height: 60px;
  box-shadow: 0px 0.5px 7px rgb(0, 0, 0, .2);
  transition-duration: 0.1s;
  transition-timing-function: linear;
  transition-delay: 0s;
  transition-property: all;
  z-index: 2;
  border-radius: 30px;
  margin: 10px 10px;
  padding: 0px 20px;

}
.el-header:hover {
  margin: 10px 8px;
  background-color: rgba(0, 0, 0, 0.4);
  box-shadow: 0px 0.5px 20px rgb(0, 0, 0, .25);


}

.blog_img > img {
  height: 40px;
  width: 40px;
  border-radius: 50%;
  margin-top: 20px;
  transform: translateX(5px);
}
.loginFROM {
  position: absolute;
  right: 100px;
  top: 250px;

}
.loginFROM:hover{
  transform: translateY(-10px);
}
/deep/ .el-card{
  border: none;
  background-color: rgba(0, 0, 0, 0.3);
  color: white;
  border-radius: 20px;
  box-shadow: 0px 0.5px 7px rgb(0, 0, 0, .2) !important;
  backdrop-filter: blur(15px)
}

.el-card:hover {
  background-color: rgba(0, 0, 0, 0.4) !important;
  box-shadow: 0px 0.5px 20px rgb(0, 0, 0, .25) !important;

}

.login_form {
  bottom: 0;
  width: 100%;
  padding: 0 50px;
  box-sizing: border-box;
  margin-bottom: 30px;

}


//加入deep权限更高
/deep/ .el-input__inner {
  //height: 50px;
border-radius: 20px;
  border: none;
  background-color: rgba(255, 255, 255, 0.247);
}

/deep/ .el-input input {
  color: #fff !important;
  margin-bottom: 20px;
}

/deep/ .el-divider {
  background-color: rgba(0, 0, 0, 0.4) !important;
  position: relative;
}

/deep/ .el-divider__text {
  position: absolute;
  background-color: rgba(0, 0, 0, 0) !important;
  padding: 0 20px;
  color: white;

}
.btns {
  display: flex;
  justify-content: right;
}
/deep/ .el-dialog{
  background-color: rgba(255, 255, 255, 0.3);
  border-radius: 20px;
  color: white;
}
/deep/.el-dialog__title{
  color: whitesmoke;
}
/deep/ .el-button{
  background: rgba(255, 255, 255, 0.247);
  border: none;
  color: white;
}
/deep/ .el-button:focus, .el-button:hover {
  color: black;
  border-color: #c6e2ff;
  background-color:gray ;
}

.img_style{
  overflow: hidden;
  height: 100px;
  width: 100px;
}
.weather{
  position: absolute;
  left: 20px;
  top: 10%;
}
.weather:hover{
  transform: translateY(-10px);
  background-color: rgba(0, 0, 0, 0.4) !important;
}
.yiqing{
  position: absolute;
  left: 200px;
  top: 10%;
}
.yiqing:hover{
  transform: translateY(-10px);
  background-color: rgba(0, 0, 0, 0.4) !important;
}
.el-col>p{
  font-size: 15px;

}
vanta-img{

}
</style>
